const rulesFn = (that) => {
  //房源信息校验
  const houseRules = {
    estateId: [
      {
        required: true, message: '请选择楼盘', trigger: 'blur'
      }
    ],
    //楼栋、单元
    houseInfo: [
      {
        required: true, message: '请选择楼栋、单元', trigger: 'blur'
      }
    ],
    floors: [
      {
        required: true, message: '请选择楼层', trigger: 'blur'
      }
    ],
    roomNumber: [
      {
        required: true, message: '请选择房间号', trigger: 'blur'
      }
    ],
    houseArea: [
      {
        required: true, message: '请输入面积', trigger: 'blur'
      },
      {
        validator: (rule, value, callback) => {
          if (value <= 0) {
            callback(new Error('面积需大于0'))
          }
          callback()
        },
        trigger: 'blur'
      }
    ],
    houseOrientation: [
      {
        required: true, message: '请选择朝向', trigger: 'blur'
      }
    ],
    roomType: [
      {
        required: true, message: '请输入室', trigger: 'blur'
      }
    ],
    hall: [
      {
        required: true, message: '请输入厅', trigger: 'blur'
      }
    ],
    toilet: [
      {
        required: true, message: '请输入卫', trigger: 'blur'
      }
    ],
    checkInNumber: [
      {
        required: true, message: '请输入可住人数', trigger: 'blur'
      },
      {
        validator: (rule, value, callback) => {
          if (value <= 0) {
            callback(new Error('可住人数需大于0人'))
          }
          callback()
        }
      }
    ],
    houseManagerId: [
      {
        required: true, message: '请选择房管家', trigger: 'blur'
      }
    ],
    proprietorUserId: [
      {
        required: true, message: '请选择业主', trigger: 'blur'
      }
    ],
    chargeType: [
      {
        required: true, message: '请选择收费方式', trigger: 'blur'
      }
    ],
    serviceCharge: [
      {
        required: true, message: '请输入账单服务费', trigger: 'blur'
      },
      {
        validator: (rule, value, callback) => {
          if (value > 100) {
            callback(new Error('账单服务费比例不能大于100'))
          }
          callback()
        }
      }
    ],
    feeAmount: [
      {
        required: true, message: '请输入费用金额', trigger: 'blur'
      },
      {
        validator: (rule, value, callback) => {
          if (value <= 0) {
            callback(new Error('费用金额需大于0元'))
          }
          callback()
        }
      }
    ],
    latestPaymentDate: [
      {
        required: true, message: '请输入最晚付款日期', trigger: 'blur'
      }
    ]

  }

  const contractRuls = {
    cooperationType: [
      {
        required: true, message: '请选择合同类型', trigger: 'blur'
      }
    ],
    signingMode: [
      {
        required: true, message: '请选择签署方式', trigger: 'blur'
      }
    ],
    contractTemplateId: [
      {
        required: true, message: '请选择合同模板', trigger: 'blur'
      }
    ],
    // contractNumber: [
    //   {
    //     required: true, message: '请输入合同编号', trigger: 'blur'
    //   }
    // ],
    servicePeriodYear: [
      {
        required: true, message: '请输入年', trigger: 'blur'
      },
      {
        validator: (rule, value, callback) => {
          if (that.form.servicePeriodMonth && that.form.servicePeriodMonth <= 0 && value <= 0) {
            callback(new Error('请输入正确月数'))
          }
          callback()
        },
        trigger: 'blur'
      }
    ],
    servicePeriodMonth: [
      {
        required: true, message: '请输入月', trigger: 'blur'
      },
      {
        validator: (rule, value, callback) => {
          if (that.form.servicePeriodYear && that.form.servicePeriodYear <= 0 && value <= 0) {
            callback(new Error('请输入正确月数'))
          }
          callback()
        },
        trigger: 'blur'
      }
    ],
    latestSigningDate: [
      {
        required: true, message: '请选择最晚签约日期', trigger: 'blur'
      }
    ],
    preparatoryPeriod: [
      {
        required: true, message: '请输入筹备期', trigger: 'blur'
      }
    ],
    monthRent: [
      {
        required: true, message: '请输入租金', trigger: 'blur'
      }
    ],
    cashPledge: [
      {
        required: true, message: '请输入押金', trigger: 'blur'
      }
    ],
    leaseStartDate: [
      {
        required: true, message: '请选择租赁周期', trigger: 'blur'
      }
    ]
  }

  return {
    ...contractRuls,
    house: houseRules
  }
}

export default {
  rulesFn
}
